from openpyxl import Workbook, load_workbook


def col_to_list(sheet, col_char):
    lst = []
    for col in sheet[col_char]:
        val = col.value
        if val:
            lst.append(val)
    return lst


def read_excel(file_name='input.xlsx'):
    wb = load_workbook(file_name)
    sheet1 = wb.worksheets[0]
    return col_to_list(sheet1, 'B'), col_to_list(sheet1, 'C')


def find_contains(sentences, keywords):
    return [s for s in sentences if any(k for k in keywords if k in s)]


def write_excel(sentences, file_name='output.xlsx'):
    wb = Workbook()
    ws = wb.active
    for i, s in enumerate(sentences):
        ws.cell(row=i + 1, column=1).value = s
    wb.save(file_name)


if __name__ == "__main__":
    sentences, keywords = read_excel()
    print(sentences)
    print(keywords)
    print('=' * 50)
    found_sentences = find_contains(sentences, keywords)
    for s in found_sentences:
        print(s)
    write_excel(found_sentences)
